{include app:admin.inc.header}

<!--tmpl-resource-->
{include app:admin.inc.top}


<div class="container-fluid content-body">
	<div class="main">
		<!-- left side start-->
		{include admin.inc.menu}
		<!-- left side end-->


		<!-- main content start-->
		<section class="right-section" id="right-section">
			<!-- start of inner-frame -->
			<div class="inner-iframe">

				<!-- page breadcrumb start-->
				{include admin.inc.bread}
				<!-- page "breadcrumb end-->
				<!-- Nav tabs -->
				<ul class="nav nav-tabs">

					<!--<li><a href="{$add_url}"><i class="glyphicon glyphicon-plus"></i> 添加订单</a></li>-->
					<li class="active"><a href="javascript:void(0);"><i class="glyphicon glyphicon-th-list"></i> 订单列表</a></li>
					<!--<li><a href="/admin/index/edit"><i class="glyphicon glyphicon-edit"></i> 编辑订单</a></li>-->

				</ul>
				<div class="inner-container">
					<form class="form-inline search-form" role="form">
						<input type="hidden" name="pagesize" value="{$pagesize}" >
						<!-- search form start -->
						<!--tmpl-search-->

						<!-- searchinput -->
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									订单号
								</div>
								<input type="text" class="form-control input-sm" maxlength="28" placeholder="" name="s_order_no" value="{$s_order_no}">
							</div>
						</div>
						
						<!-- searchinput -->
						<div class="form-group">
							<select class="form-control input-sm" name="s_consignee_type">
								<option value="0" {if $s_consignee_type!=1}selected{/if}>收货人</option>
								<option value="1" {if $s_consignee_type==1}selected{/if}>提货人</option>
							</select>
						</div>
						<div class="form-group">
							<input type="text" class="form-control input-sm" maxlength="{maxlength}" placeholder="" name="s_consignee" value="{$s_consignee}">
						</div>
						
						<!-- searchinput -->
						<div class="form-group">
							<select class="form-control input-sm" name="s_contact_type">
								<option value="0" {if $s_contact_type!=1}selected{/if}>收货人电话</option>
								<option value="1" {if $s_contact_type==1}selected{/if}>提货人电话</option>
							</select>
						</div>
						<div class="form-group">
							<input type="text" class="form-control input-sm" maxlength="{maxlength}" placeholder="联系电话" name="s_contact_mobile" value="{$s_contact_mobile}">
						</div>
						
						<!-- searchinput -->
						<div class="form-group">
							<div class="input-group">
								{setSelectOptions $option_arr s_order_status $s_order_status '-订单状态-' ''}
							</div>
						</div>
						
						<!-- searchdatetime -->
						<div class="form-group">
							<select class="form-control input-sm" name="s_time_type">
								<option value="0" {if $s_time_type!=1}selected{/if}>下单时间</option>
								<option value="1" {if $s_time_type==1}selected{/if}>付款时间</option>
							</select>
							<div class="input-group">
								<input style="width:100px;" class="form-control form-control-inline input-sm mdate"  size="16" type="text"
								name="s_s_order_time" value="{$s_s_order_time}"
								placeholder="开始时间" />

								<div class="input-group-addon">
									-
								</div>
								<input style="width:100px;" class="form-control form-control-inline input-sm mdate"  size="16" type="text"
								name="s_e_order_time" value="{$s_e_order_time}"
								placeholder="结束时间" />
							</div>
						</div>


						<input type="hidden" name="order" value="{$order}">
						<input type="hidden" name="pagesize" value="{$pagesize}">
						<button type="submit" class="btn btn-sm btn-success">搜索</button>
						{run exportBtn()}
						<!-- search form end -->
					<!--</form>
					<form id="J_List_Form">-->
						<div class="table-responsive">
							<table id="J_ListTable" class="table  table-hover  table-striped">
								<!--tmpl-listtable-->

								<!-- listblock -->
								<thead>
									<tr>
										<th width="20"><input type="checkbox" class="icheck check-all" /></th>
										<th>订单号</th>
										<th>总金额</th>
										<th>应付金额</th>
										<th>支付方式</th>
										<th>配送方式</th>
										<th>下单时间</th>
										<th>订单状态</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
								{if empty($items)}
								<tr>
									<td style="text-align:center;" colspan="14" class="empty-table-td">{$emptyRecord}</td>
								</tr>
								{/if}
								{loop $items $v}
								<tr>
									<td><input type="checkbox" class="icheck" name="ids[]" value="{$v[id]}"/></td>
									<!--tmpl-fieldlist-->
								
									<td>{$v[order_no]}</td>
									<td>{$v[amount]}</td>
									<td>{$v[actual_amount]}</td>
									<td>{$v[payway]}</td>
									<td>{$v[shippingway]}
										(
										{if $v[shipping_way]==$SHIPPING_WAY_BUYER}
										提货人:{$v[shipping_fullname]}&nbsp;
										提货人电话:{$v[shipping_mobile]}
										{else}
										收货人:{$v[consignee]}&nbsp;
										收货人电话:{$v[contact_mobile]}
										{/if}
										)
									</td>
									<td>{$v[order_time]}</td>
									<td>{$v[orderstatus]}</td>
								
									<td>
										<input type="hidden" value="{$v[member_id]}" name="member_id">

										{if in_array('admin/order/detail',$priv) || empty($priv)}

										    <a href="{$detail_url}?id={$v[id]}" class="btn btn-primary btn-xs">
											  <i class="glyphicon glyphicon-info-sign"></i> 详情
											</a>

                                        {/if}

										{if $v[order_status]<=$ORDER_STATUS_UNPAY}
											{if $v[order_status]==$WAIT_FOR_MERCHANT_CONFIRMATION}
											{if in_array('admin/order/merchantConfirmation',$priv) || empty($priv)}
											<a href="javascript:void(0);" data-id="{$v[id]}" class="btn btn-primary btn-xs confirmation">
												确认订单</a>
											{/if}
											{/if}
										   {if in_array('admin/order/edit',$priv) || empty($priv)}
											<a href="{$edit_url}?id={$v[id]}" class="btn btn-primary btn-xs">
											 <i class="glyphicon glyphicon-edit"></i> 编辑</a>
										   {/if}
										    {if in_array('admin/order/cancelorder',$priv) || empty($priv)}
										      <a href="javascript:void(0);" data-id="{$v[id]}" class="btn btn-danger btn-xs cancelOrder">
											     <i class="glyphicon glyphicon-trash"></i> 取消</a>
										    {/if}
										{/if}

										{if ($v[order_status]==$ORDER_STATUS_UNPAY && $v[pay_way]==$PAY_WAY_OFFLINE) || $v[order_status]==$ORDER_PENDING_RECEIPT}
										   {if in_array('admin/order/confirmorderpay',$priv) || empty($priv)}
											  <a href="javascript:void(0);" data-id="{$v[id]}" class="btn btn-primary btn-xs select_record">
											   确认收款</a>
										   {/if}
										{/if}

										{if $v[order_status]==$ORDER_STATUS_TO_BE_SHIPPED}
										    {if in_array('admin/order/delivery',$priv) || empty($priv)}
												{if $v[shipping_way]==$SHIPPING_WAY_BUYER}
												<a href="javascript:void(0);" data-id="{$v[id]}" class="btn btn-primary btn-xs delivery">
													发货
												</a>
												{else}
												<a href="javascript:void(0);" data-id="{$v[id]}" class="btn btn-primary btn-xs popwin" data-template="content-add-template">
													发货
												</a>
												{/if}

										    {/if}
										{/if}
									</td>
								</tr>
								{/loop}
								

							</table>

						</div>
						
					</form>
					<div class="text-right">
						{$pagemenu}
					</div>

				</div>
			</div>
		</section>
	</div>
</div>

<!--footer section start-->
{include admin.inc.footer}
<!--footer section end-->

<!--tmpl-script-->

<!-- template -->
<script type="text/html" id="content-add-template">
	<div class="pop-layer-box">
		<form role="form" class="content-add-form" id="content-add-form" autocomplete="off">
			<div class="form-group">
				<label><span class="asterisk">*</span>送货人姓名</label>
				<input type="text" name="data[shipping_fullname]" class="form-control" placeholder="送货人姓名" value="" required />
			</div>
			<p class="help-block text-error"></p>

			<div class="form-group">
				<label><span class="asterisk">*</span>送货人手机号码</label>
				<input type="text" name="data[shipping_mobile]" dtype="mobile" class="form-control" placeholder="送货人手机号码" value="" required />
			</div>
			<p class="help-block text-error"></p>

			<div class="form-group">
				<label><span class="asterisk">*</span>送货车辆牌号</label>
				<input type="text" name="data[shipping_car_card]" class="form-control" placeholder="送货车辆牌号" value="" required />
			</div>
			<p class="help-block text-error"></p>

			<div class="form-group">
				<label>送货人身份证</label>
				<input type="text" name="data[shipping_id_card]" class="form-control" value="" placeholder="送货人身份证" />
			</div>

			<div class="form-group">
				<label><span class="asterisk">*</span>送货日期</label>
				<input style="width:100px;" class="form-control mdate" dtype="time" size="16" type="text"
					   name="data[shipping_time]" value=""
					   placeholder="送货日期" required />
			</div>
			<p class="help-block text-error"></p>

			<div class="form-group">
				<label>发货补充</label>
				<textarea name="data[shipping_remark]" class="form-control"></textarea>
			</div>
			<input type="hidden" name="id" value="{[id]}" />
		</form>
	</div>
</script>

<!-- pagescript -->
<script type="text/javascript">
	seajs.use("admin/trading_orderindex",function (exports){
		exports.init({
			billRecordsUrl : '/admin/order/billRecords',//获取资金流水
			confirmOrderPayUrl : '/admin/order/confirmOrderPay',//确认收款
			addShippingUrl : '/admin/order/delivery',//发货
			merchantConfirmationUrl : '/admin/order/merchantConfirmation',//确认订单
			cancelOrderUrl : '/admin/order/cancelOrder',//取消订单
		});
	});
</script>


<script id="assocpage" type="text/html">
<div class="text-right">
	<ul class="pagination blog-pagination">
		<li><a class="assoc-page" data-page="{[prev]}" href="javascript:void(0);">上一页</a></li> 
		{[loop pages page]}

		<li {[if curr == page]}class="active"{[/if]}><a class="assoc-page" data-page="{[page]}"  href="javascript:void(0)">{[page]}</a></li> 

		{[/loop]}
		<li><a class="assoc-page" href="javascript:void(0);" data-page="{[nexts]}">下一页</a></li> 
	</ul>	
</div>
</script>
</body>
</html>
